<?php


namespace App\Api\Models;


use Illuminate\Database\Eloquent\Model;

class  CmcPromotionPintuan  extends  Model
{
    protected $table='cmc_promotion_pintuan';

    //获得需要的数据
    static public function oncePintuan($pid,$allow_field)
    {
        return CmcPromotionPintuan::where('pintuan_id',$pid)->get($allow_field)->toArray()[0];
    }

    //图片访问器
    public function getPintuanImageAttribute($value)
    {
        return config('aliyun.cui').$this->attributes['pintuan_image'];
    }

    //时间段区间查询
    static public function inTime($time,$allow_field = null)
    {
        return CmcPromotionPintuan::where('start_time','<',$time)->where('end_time','>',$time)->get($allow_field)->toArray();
    }
    //获取活动商品详情
    static public function getGoodsDetail($pid,$allow_field)
    {
        return CmcPromotionPintuan::where('pintuan_id',$pid)->get($allow_field)->toArray()[0];
    }
    // 查询拼团详情
    static public function getPinkInfo($id){
        return CmcPromotionPintuan::where('pintuan_id',$id)->get($id)->toArray();
    }
}
